'use strict'

const config = {
    store: {
        path: 'store/',
        use_mock: location.search.startsWith('?mock'),
        extra_modules: ['chat', 'salary', 'article', 'contacts', 'complaints', 'gallery', 'parking', 'train']
    },
    components: [
        {name: 'we-menu', path: 'components/WechatMenu.vue'},
        {name: 'animate-list', path: 'components/AnimateList.vue'},
        {name: 'animate-item', path: 'components/AnimateItem.vue'},
        {name: 'custom-keyboard', path: 'components/CustomKeyboard.vue'},
        {name: 'guesture-lock', path: 'components/GuestureLock.vue'},
        {name: 'ui-changepassword', path: 'pages/me/password.vue'},
        {name: 'ui-changeinfo', path: 'pages/me/edit.vue'},
        {name: 'ui-contact', path: 'pages/contacts/detail.vue'},
        {name: 'ui-complain', path: 'pages/complaints/detail.vue'},
        {name: 'ui-gallery', path: 'pages/gallery/detail.vue'}
    ],
    error: (e) => {
        const Err = httpVueLoader('err.vue')
        new Vue({
            el: '#app',
            store: {
                state: {
                    message: e
                }
            },
            template: '<Err/>',
            components: {
                Err
            }
        })
        if(config.store.use_mock) {
            throw e
        }
    }
}

function channelId(path) {
    const m = path.match(/\/(\d+)$/)
    if(m && m[1]) {
        return m[1]
    } else {
        return 0
    }
}

/***************
自定义模块指南
================
- 定义数据结构：store/mock/data/模块/数据名称.json
- 定义数据访问接口（API）：store/mock/index.js
- 定义数据使用接口（store）：store/模块/index.js
- 定义页面：pages/模块/index.vue
- 添加模块到extra_modules列表

使用地址/static/app/?mock进行本地测试
***************/